﻿@model Property4U.Models.Order

@{
    ViewBag.Title = "Edit";
}

<div class="row">
    <!-- Page Header -->
    <div class="col-lg-12">
        <h1 class="page-header">@ViewBag.Title</h1>
    </div>
    <!--End Page Header -->
</div>

@using (Html.BeginForm(null, null, FormMethod.Post, new { enctype = "multipart/form-data" }))
{
    @Html.AntiForgeryToken()
    
    <div class="form-horizontal">
        <h4>Order</h4>
        <hr />
        @Html.ValidationSummary(true, "", new { @class = "text-danger" })
        @Html.HiddenFor(model => model.ID)

        <div class="form-group">
            @Html.LabelFor(model => model.AgentID, "AgentID", htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.DropDownList("AgentID", (SelectList)ViewBag.AgentIDList, String.Empty, htmlAttributes: new { @class = "form-control" })
                @Html.ValidationMessageFor(model => model.AgentID, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.Title, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.Title, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.Title, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.Description, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.Description, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.Description, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.Size, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EnumDropDownListFor(model => model.Size, htmlAttributes: new { @class = "form-control" })
                @Html.ValidationMessageFor(model => model.Size, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.NumberOfAds, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.NumberOfAds, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.NumberOfAds, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.ZipFilePath, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @*@Html.EditorFor(model => model.ZipFilePath, new { htmlAttributes = new { @class = "form-control" } })*@
                <input type="file" accept="application/iso,application/rar,application/zip" name="orderFile" id="orderFile" value="Choose File" class="form-control" />
                @Html.HiddenFor(model => model.ZipFilePath, new { id = "ZipFilePath" })
                <p style="font-size:small; color:#428bca;">current selected file <a href="@Url.Content("~/Content/Uploads/Orders/" + Model.ZipFilePath)"><b>@Html.DisplayFor(model => model.ZipFilePath)</b></a></p>
                <input type="hidden" name="oldOrderPath" id="oldOrderPath" value="@Html.DisplayFor(model => model.ZipFilePath)" />
                @Html.HiddenFor(model => model.ZipFileSize, new { id = "ZipFileSize" })
                @Html.ValidationMessageFor(model => model.ZipFilePath, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.AdsDuration, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EnumDropDownListFor(model => model.AdsDuration, htmlAttributes: new { @class = "form-control" })
                @Html.ValidationMessageFor(model => model.AdsDuration, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.Date, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.Date, new { htmlAttributes = new { @class = "form-control", @readonly = "readonly" } })
                @Html.ValidationMessageFor(model => model.Date, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.OrderStatus, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EnumDropDownListFor(model => model.OrderStatus, htmlAttributes: new { @class = "form-control", @disabled = "disabled" })
                @Html.HiddenFor(model => model.OrderStatus, new { id = "RequestStatus", @Value = ViewBag.OrderStatus })
                @Html.ValidationMessageFor(model => model.OrderStatus, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.Remedies, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.Remedies, new { htmlAttributes = new { @class = "form-control", @readonly = "readonly" } })
                @Html.ValidationMessageFor(model => model.Remedies, "", new { @class = "text-danger"})
            </div>
        </div>

        @Html.HiddenFor(model => model.LastEdit, htmlAttributes: new { @Value = ViewBag.LastEdit })

        <div class="form-group">
            <div class="col-md-offset-2 col-md-10">
                <input type="submit" value="Save" class="btn btn-default" />
            </div>
        </div>
    </div>
}

<div>
    @Html.ActionLink("Back to List", "Index")
</div>

@section scripts {
    <script type="text/javascript">
        jQuery('#orderFile').change('input propertychange paste', function () {
            $("#ZipFilePath").val($(this).val());
            });
    </script>
}